<div id="form"></div>
<script>
var frm=$("#form").ajajform({
	header: null,
	footerButtons: [
		{value: "{{modeldef.label_create}}",url: "<{>action<}>?mode=edit{{modeldef.create_link_add}}"}{{modeldef.list_footer_buttons_html_add}}
	]
});
var grid=frm.ajajform("insertWidget",null,null,{
	type: "grid",
	title: "{{modeldef.label_title}}",
	name: "{{modeldef.name_many}}",
	sort: {{modeldef.list_has_sort}}?{url: "<{>action<}>",params: {mode: "reorder", ajaj: 1}}:null,
	rowClasses: [{
		name:"{{modeldef.name}}",
		sortable: {{modeldef.list_has_sort}},
		columns: {{JSON:modeldef.list_columns}}
	}]
});
var {{modeldef.name_many}}=<{>JSON:{{modeldef.name_many}}<}>;
for (var i=0;i<{{modeldef.name_many}}.length;i++) {
	var item={{modeldef.name_many}}[i];
	grid.ajajform_grid("insertRow",null,{rowClass: "{{modeldef.name}}",cells:[{{modeldef.list_cells}}],id:item.id,level:item.level?item.level-1:undefined});
}
</script>

